package com.hzeport.bgs22emduty.outbound.db;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hzeport.bgs22emduty.common.base.BaseRepositoryImpl;
import com.hzeport.bgs22emduty.entity.ParamDuty;
import com.hzeport.bgs22emduty.outbound.db.mapper.ParamDutyMapper;
import com.hzeport.bgs22emduty.outbound.ParamDutyRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 参数表-值班配置表：
此表中存储，各部门值班的参数配置
 *
 * @author code generator
 * @date 2022-12-02 11:21:59
 */
@Service
@Slf4j
public class ParamDutyRepositoryImpl extends BaseRepositoryImpl<ParamDutyMapper, ParamDuty> implements ParamDutyRepository {


    @Override
    public ParamDuty getByIdIfDel(String id) {
        return mapper.getByIdIfDel(id);
    }

    @Override
    public Map<String, ParamDuty> queryRltParamDuty(List<String> paramDutyIds) {
        if (CollectionUtils.isEmpty(paramDutyIds)) {
            return new HashMap<>();
        }
        return list(new LambdaQueryWrapper<ParamDuty>().in(ParamDuty::getId, paramDutyIds)).stream()
                .collect(Collectors.toMap(ParamDuty::getId, Function.identity()));
    }
}
